package cn.zl.springcloud;


import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

import javax.servlet.ServletRegistration;

/**
 * @author zhanglang
 * @Date 2020/4/10
 */
@SpringBootApplication
@EnableEurekaClient
/*@EnableDiscoveryClient*/
@EnableCircuitBreaker
public class DeptProvider_8001 {
    /**
     * @EnableEurekaClient 在服务启动后根据配置自动注册到服务端
     * @param args
     */
    public static void main(String[] args) {
        SpringApplication.run(DeptProvider_8001.class, args);
    }

    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet(){
        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
        registrationBean.addUrlMappings("/actuator/hystrix.stream  ");
        registrationBean.setName("HystrixMetricsStreamServlet");
        return registrationBean;
    }

}
